import requests
import subprocess
from functools import partial
subprocess.Popen = partial(subprocess.Popen, encoding="utf-8")
import execjs
import time


timestamp = str(int(time.time()*1000))
print(timestamp)

def encry_param():
    with open("sn参数.js","r",encoding="utf-8")as f:
        data = f.read()
    js = execjs.compile(data)
    return js.call("result",timestamp,str(3))

headers = {
    "Accept": "application/json, text/javascript, */*; q=0.01",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Connection": "keep-alive",
    "Referer": "https://www.mafengwo.cn/hotel/92799.html?iMddid=10189",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "X-Requested-With": "XMLHttpRequest",
    "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\""
}
cookies = {
    "__jsluid_s": "0ae22aeee6a08c7e63e58e548aaaeb34",
    "mfw_uuid": "65911ddf-b62a-8010-d95f-e4c6ed90e9f6",
    "oad_n": "a%3A3%3A%7Bs%3A3%3A%22oid%22%3Bi%3A1029%3Bs%3A2%3A%22dm%22%3Bs%3A15%3A%22www.mafengwo.cn%22%3Bs%3A2%3A%22ft%22%3Bs%3A19%3A%222023-12-31+15%3A53%3A03%22%3B%7D",
    "__mfwc": "direct",
    "uva": "s%3A92%3A%22a%3A3%3A%7Bs%3A2%3A%22lt%22%3Bi%3A1704009186%3Bs%3A10%3A%22last_refer%22%3Bs%3A24%3A%22https%3A%2F%2Fwww.mafengwo.cn%2F%22%3Bs%3A5%3A%22rhost%22%3BN%3B%7D%22%3B",
    "__mfwurd": "a%3A3%3A%7Bs%3A6%3A%22f_time%22%3Bi%3A1704009186%3Bs%3A9%3A%22f_rdomain%22%3Bs%3A15%3A%22www.mafengwo.cn%22%3Bs%3A6%3A%22f_host%22%3Bs%3A3%3A%22www%22%3B%7D",
    "__mfwuuid": "65911ddf-b62a-8010-d95f-e4c6ed90e9f6",
    "__jsl_clearance_s": "1704074096.049|0|%2B%2F8sbq6oXvNxZYPtwGceLasEs4c%3D",
    "PHPSESSID": "ageqd4f3joc7s6kr8uuo8d0oj5",
    "__mfwb": "ec9d1f163744.1.direct",
    "__mfwa": "1704009185006.69525.2.1704009185006.1704074099164",
    "__mfwlv": "1704074099",
    "__mfwvn": "2",
    "__mfwlt": "1704074099",
    "Hm_lvt_8288b2ed37e5bc9b4c9f7008798d2de0": "1704009188,1704074100",
    "Hm_lpvt_8288b2ed37e5bc9b4c9f7008798d2de0": "1704074100",
    "bottom_ad_status": "0"
}
url = "https://www.mafengwo.cn/hotel/info/comment_list"
params = encry_param()

response = requests.get(url, headers=headers, cookies=cookies, params=params)

print(response.json())
